package com.example.myapplication2048.itemprovider;

import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.PageSliderProvider;

import java.util.List;

public class MainBodyContentProvider extends PageSliderProvider {
    private List<DirectionalLayout> layouts;//页面内容

    public MainBodyContentProvider(List<DirectionalLayout> layouts) {
        this.layouts = layouts;
    }

    @Override
    public int getCount() {
        return layouts.size();
    }

    @Override
    public Object createPageInContainer(ComponentContainer componentContainer, int i) {
        componentContainer.addComponent(layouts.get(i));
        return layouts.get(i);
    }

    @Override
    public void destroyPageFromContainer(ComponentContainer componentContainer, int i, Object o) {
        componentContainer.removeComponent((Component )o);
    }

    @Override
    public boolean isPageMatchToObject(Component component, Object o) {
        return component==o;
    }


}
